//
//  NSUserDefaults+General.swift
//  YOKO
//
//  Created by 鲁浩 on 16/5/22.
//  Copyright © 2016年 15Tec. All rights reserved.
//

import Foundation

public extension NSUserDefaults {
    
    static func getCurrentCalendarId() -> String {
        return NSUserDefaults.standardUserDefaults().stringForKey("current_calendar_id")!
    }
    
    static func setCurrentCalendarId(calendarId: String) {
        NSUserDefaults.standardUserDefaults().setObject(calendarId, forKey: "current_calendar_id")
        NSNotificationCenter.defaultCenter().postNotificationName(YOKONotification.CHANGE_CURRENT_CALENDAR, object: nil)
    }
    
    static func isFirstLaunch() -> Bool {
        return NSUserDefaults.standardUserDefaults().boolForKey("first_launch_flag")
    }
    
    static func firstLaunch() {
        NSUserDefaults.standardUserDefaults().setBool(true, forKey: "first_launch_flag")
    }
    
    static func getAccessToken() -> String? {
        return NSUserDefaults.standardUserDefaults().stringForKey("access_token")
    }
    
    static func setAccessToken(access_token: String?) {
        NSUserDefaults.standardUserDefaults().setObject(access_token, forKey: "access_token")
    }
    
    static func getSyncToken() -> String? {
        return NSUserDefaults.standardUserDefaults().stringForKey("sync_token")
    }
    
    static func setSyncToken(sync_token: String) {
        NSUserDefaults.standardUserDefaults().setObject(sync_token, forKey: "sync_token")
    }
    
    static func getPhoneNumber() -> String? {
        return NSUserDefaults.standardUserDefaults().stringForKey("phone_number")
    }
    
    static func setPhoneNumber(phone: String) {
        NSUserDefaults.standardUserDefaults().setObject(phone, forKey: "phone_number")
    }
}